/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: app2022 - T23
 * <p>Powered by webrx On 2022-02-07 16:19:13
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T23 {
    public static void main(String[] args) {
        var t = new Thread(() -> {
            String tn = Thread.currentThread().getName();
            System.out.printf("%s启动%n", tn);
            while (true) {
                try {
                    TimeUnit.SECONDS.sleep(1);
                    System.out.println("worker...");
                } catch (Exception e) {
                    System.out.printf("%s中断%n", tn);
                    System.out.printf("%s结束%n", tn);
                    break;
                }
            }
        }, "T1");
        t.start();

        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (Exception e) {
            e.printStackTrace();
        }
        t.interrupt();

    }
}
